package com.stegniy.anagram;

import java.io.*;
import java.util.*;

public class AnagramWriter {

    public static void write(String fileName, List<List<String>> anagram) {

        File file = new File(fileName);
        String text = "";

        for (int i = 0; i < anagram.size(); i++) {
            text = text + anagram.get(i) + "\n";
        }

        try {
            if(!file.exists()){
                file.createNewFile();
            }

            PrintWriter out = new PrintWriter(file.getAbsoluteFile());

            try {
                out.print(text);
            } finally {
                out.close();
            }
        } catch(IOException e) {
            throw new RuntimeException(e);
        }
    }
}
